﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Diagnostics;
using Lime49.UI;

namespace LaunchMeNot
{
    /// <summary>
    /// The 'About LaunchMeNot' window.
    /// </summary>
    public partial class WinAbout : Window {
        public WinAbout() {
            InitializeComponent();
        }

        /// <summary>
        /// Sets the version and build date text when the window loads.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void Window_Loaded(object sender, RoutedEventArgs e) {
            lblVersion.Text = Lime49.Utils.GetVersion().ToString();
            lblDate.Text = Lime49.Utils.RetrieveLinkerTimestamp().ToUniversalTime().ToString("d/MM/yyyy HH:mm") + " UTC";
            txtCopyright.Text = string.Format("Copyright ©2009-{0} Harry Jennerway", Math.Max(DateTime.Now.Year, 2010));
        }

        /// <summary>
        /// Opens a URL.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.Windows.Navigation.RequestNavigateEventArgs"/> instance containing the event data.</param>
        private void OpenURL(object sender, System.Windows.Navigation.RequestNavigateEventArgs e) {
            string url = e.Uri.ToString();
            if(url.Length > 0) {
                try {
                    Process.Start(url);
                } catch (Exception ex) {
                    DialogBox.ShowAlert(this, ex.Message, I18nUtils.GetString("Errors", "Error"));
                }
            }
        }

        /// <summary>
        /// Shows a photo of ME when the user clicks "Harry Jennerway" and holds shift, ctrl or alt.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Input.MouseEventArgs"/> instance containing the event data.</param>
        private void hjennerway_MouseDown(object sender, MouseEventArgs e) {
            if(Keyboard.Modifiers != ModifierKeys.None) {
                imgLogo.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/Images/hjennerway_cigar.png", UriKind.Absolute));
            }
        }
    }
}
